import 'package:flutter/material.dart';
import 'package:time/pages/file_page.dart';
import 'package:time/pages/home_page.dart';
import 'package:time/pages/http_page.dart';
import 'package:time/pages/startup_page.dart';

class RouteApp extends StatelessWidget {
  const RouteApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const RoutePage(),
      title: "导航",
      theme: ThemeData(primaryColor: Colors.orange),
    );
  }
}

class RoutePage extends StatefulWidget {
  const RoutePage({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return RouteState();
  }
}

class RouteState extends State {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: const Text("导航"),
      ),
      body: Column(
        children: [
          MaterialButton(
              child: const Text("秒表"),
              color: Colors.orange,
              onPressed: () => {jump(const MyApp())}),
          MaterialButton(
              child: const Text("文件"),
              color: Colors.orange,
              onPressed: () => {jump(const FileApp())}),
          MaterialButton(
              child: const Text("网络"),
              color: Colors.orange,
              onPressed: () => {jump(const HttpPage())}),
          MaterialButton(
              child: const Text("启动"),
              color: Colors.orange,
              onPressed: () => {jump(const StartUpPage())}),
        ],
      ),
    );
  }

  jump(Widget page) {
    Navigator.push(
            context,
            MaterialPageRoute(
                settings:
                    const RouteSettings(name: "route_page", arguments: "这是参数哇"),
                builder: (context) => page))
        .then((value) => {print(value.toString())});
  }
}
